package com.ms.oschina.util;

import java.util.ArrayList;

import android.graphics.drawable.Drawable;
import android.text.style.ImageSpan;

import com.ms.oschina.R;
import com.ms.oschina.emoji.DisplayRules;

public class EmojiUtils {
	public static ImageSpan getEmojiImgSpan(int rid, int pixelSize) {
		Drawable drawable = UiUtils.getContext().getResources()
				.getDrawable(rid);
		drawable.setBounds(0, 0, pixelSize, pixelSize);
		// http://blog.csdn.net/llping2011/article/details/10301291

		return new ImageSpan(drawable);// 要让图片替代指定的文字就要用ImageSpan
	}

	public static int getEmojiResId(String emmjiStr) {
		DisplayRules[] values = DisplayRules.values();
		for (int i = 0; i < values.length; i++) {
			DisplayRules displayRules = values[i];
			if (displayRules.getEmojiStr().equals(emmjiStr)) {
				return displayRules.getResId();
			}
		}
		return -1;
	}

}
